#ifndef PICKER_H
#define PICKER_H

#include <OgreNewt.h>
#include <OgreSceneManager.h>

#include <OIS.h>

class Picker : public Ogre::Singleton<Picker>
{
public:
	Picker();
    ~Picker();

    void init(Ogre::SceneManager* sceneManager, OgreNewt::World* world, OIS::Keyboard* keyboard, OIS::Mouse* mouse, int maxDistance = 2000, int forceMultiplier = 10);
    void deInit();
    void update(Ogre::Camera* camera);

    void dragCallback(OgreNewt::Body* body, Ogre::Real timeStep, int threadIndex);

    static Picker& getSingleton(void);
	static Picker* getSingletonPtr(void);

private:
	Ogre::SceneManager* sceneManager;
    Ogre::Camera* camera;
	Ogre::SceneNode* dragLineNode;
    Ogre::ManualObject* dragLineObject;
	Ogre::Vector3 dragPoint;
    Ogre::Real dragDist;

	OIS::Keyboard* keyboard;
	OIS::Mouse* mouse;

	OgreNewt::World* world;
    OgreNewt::Body* dragBody;
	OgreNewt::Body::ForceCallback previousForceTorqueCallback;

    bool active;
    bool dragging;
    int maxDistance;
    int forceMultiplier;

    void removeLine();
};

#endif // PICKER_H
